package com.lyf.language.learn.atsgg.java8.optional;

import org.junit.Test;

import java.util.LinkedList;
import java.util.List;
import java.util.Optional;

/**
 * @AUTHOR LYF
 * @DATE 2022/6/7
 * @VERSION 1.0
 * @DESC
 * get , of -- know it not null
 *
 */
public class OptionalTests {
    @Test
    public void test1(){

//        Optional<int> optionalI = null;
//        optionalI.ifPresent(e->{});
        Integer i=null;
        Optional.ofNullable(i);
        Optional.of(i);
    }

    @Test
    public void test2(){
       // List<Optional<Integer>> list = new LinkedList<>();
        //Optional<List<Integer>> list1 = new Optional<>();
          Optional<Person> person = Optional.ofNullable(null);//new Person()
          Person person1 = person.orElse(new Person("Hello",1));
          System.out.println(person1.getName());
    }

}
